package com.bdqn.crm.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bdqn.crm.mapper.StorageMapper;
import com.bdqn.crm.mybatis.ServiceImpl;
import com.bdqn.crm.pojo.Pagee;
import com.bdqn.crm.pojo.Storage;
import com.bdqn.crm.pojo.SysRole;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class StorageServiceImpl extends ServiceImpl<StorageMapper, Storage> implements StorageService {
    @Resource
    private StorageMapper storageMapper;

//    @Override
//    public Pagee pagee(String prodName, String stkWarehouse, int pageIndex) {
//        Pagee<Storage> pagee = new Pagee<>();
//
//        //从数据库第几行开始查询
//        int startPage = (pageIndex -1) * pagee.getPageCount();
//        //查询多少行数据，默认5行
//        int selectPage = pagee.getPageCount();
//        //获取mapper层数据
//        List<Storage> list = storageMapper.list(prodName,stkWarehouse,startPage,selectPage);
//
//        QueryWrapper<Storage> queryWrapper = new QueryWrapper<>();
//        Map map = new HashMap();
////        map.put("prod_name",prodName);
//        map.put("stk_warehouse",stkWarehouse);
//        queryWrapper.allEq(map,false);
//        //获取总数
//        int count = storageMapper.selectCount(queryWrapper);
//        pagee.setNumber(pageIndex);
//        //设置查询的数据
//        pagee.setContent(list);
//        //共多少行数据
//        pagee.setTotalElements(count);
//        return pagee;
//    }

    @Override
    public IPage<Storage> page(String prodName, String stkWarehouse, Page page) {
        return this.getPage(page, new Storage(prodName,stkWarehouse));
    }
}
